/*
 * 产品搜索
 * @Author: ljb
 * @Date: 2018-03-27 17:51:07
 * @Last Modified by: kanglin
 * @Last Modified time: 2018-06-05 09:57:09
 */
<template>
	<Form
		ref="formInline"
		inline
		@keydown.native.enter.prevent="confirmSearch">

		<Form-item
			:label-width="80"
			:label="$t('brand.product_type')"
			porp="product_type_id">
			<Select
				v-model="formValidate.customer_id"
				clearable
				filterable
				transfer>
				<Option
					v-for="( value , key ) in customers"
					:value="key + ''"
					:key="key">{{ value }}</Option>
			</Select>
		</Form-item>

		<Form-item
			:label-width="80"
			:label="$t('brand.is_sale')"
			porp="is_sale">
			<Select
				v-model="formValidate.is_sale"
				clearable
				transfer>
				<Option
					v-for="status in true_false_status"
					:value="status.value"
					:key="status.value">{{ status.label }}</Option>
			</Select>
		</Form-item>

		<Form-item
			:label-width="80"
			:label="$t('brand.is_deleted')"
			porp="is_deleted">
			<Select
				v-model="formValidate.is_deleted"
				clearable
				transfer>
				<Option
					v-for="status in true_false_status"
					:value="status.value"
					:key="status.value">{{ status.label }}</Option>
			</Select>
		</Form-item>

		<Form-item>
			<Button
				type="primary"
				@click="confirmSearch">
				{{ $t('common.search') }}
			</Button>
		</Form-item>

	</Form>
</template>
<script>

export default {

	name: 'BrandSearchForm',

	props: {
		customers: {
			type: Object,
			default() {
				return {};
			},
		},
	},

	data() {
		return {
			true_false_status: [
				{
					label: this.$t('common.no'), // 否
					value: '0',
				},
				{
					label: this.$t('common.yes'), // 是
					value: '1',
				},
			],
			formValidate: {
				customer_id: '',

				is_sale: '',

				is_deleted: '',
			}, // 搜索框的对象参数
		};
	},

	methods: {

		/**
         * 确认搜索
         * @return {undefined}
         */
		confirmSearch() {
			const param = {
				customer_id: this.formValidate.customer_id,

				is_sale: this.formValidate.is_sale,

				is_deleted: this.formValidate.is_deleted,
			};

			this.$emit('search', param);
		},

	},

};

</script>
